package model;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Observable;
import java.util.Observer;

import javax.imageio.ImageIO;

public class World extends Observable{

	static List<Observer> observerList;
	BufferedImage backgroundImage;
	Color backgroundColor;
	String imagePath;
	Dimension myBounds = new Dimension(); //get height and width from model
	private Model myModel;
	
	public World(Model model, int x, int y){
		myModel = model;
		setBounds(x,y);
		backgroundColor = Color.WHITE;
	}
	
	public World(Model model, int y, int x, String imagePath) {
		myModel = model;
		setBounds(x,y);
		this.imagePath = imagePath;
		try
		{
		backgroundImage = ImageIO.read(new File(imagePath));
		}catch(IOException e)
		{
			
		}
	}
	
	public void setBackgroundImage(String path) {
		imagePath = path;
		try {
		backgroundImage = ImageIO.read(new File(imagePath));
		}catch(IOException e) {
			System.out.println("image not found");
		}
		myModel.notifyObservers(myModel.WORLD_OBSERVER);
	}
	
	public String getBackgroundImagePath(){
		return imagePath;
	}
	
	public Color getBackground(){
		return backgroundColor;
	}
	
	public BufferedImage getBackgroundImage(){
		return backgroundImage;
	}
	
	public Dimension getBounds(){
		return myBounds;
	}
	
	public void setBounds(Dimension dim){
		myBounds = new Dimension(dim);
	}
	
	public void setBounds(int x, int y){
		setBounds(new Dimension(x, y));
	}
	
	public void notifyObservers() {
		myModel.notifyObservers("world");
	}

	public void addModelObserver(Model model) {
		myModel = model;
	}
	
}
